using System;
using System.Data;
using DataScripter.Scripting.Compare.DataTables.Structure;

namespace DataScripter.Util
{
    internal static class Guard
    {
        internal static void TablesShouldHaveSameStructure(DataTable table1, DataTable table2)
        {
            DataTableStructureComparer structureComparer = new DataTableStructureComparer(table1, table2);
            DataTableStructureComparisonResult comparisonResult = structureComparer.Compare();
            if (!comparisonResult.IsSame())
                throw new ArgumentException("Table structures are not equal", "table1");
        }

        public static void TableShouldHavePrimaryKey(DataTable dataTable)
        {
            if (dataTable.PrimaryKey.Length == 0)
                throw new ArgumentException("Table does not have primary key", "dataTable");
        }
    }
}